count
$count
Counts the number of documents input to the $count stage and outputs the document count with your custom field name to the next phase in the aggregation pipeline.
Syntax
{ "$count": "<string>" }
For the <string> placeholder, enter a custom name for the output field that has the count as its value. The string you enter cannot contain the following:
- The special character,
. - The special character,
$, at the start of the string - An empty string
Sample Request
[
{
"$match": {
"temp": {
"$gt": 10
}
}
},
{
"$count": "tempGreaterThan10"
}
]
Sample Response
{
"_list": [
{
"tempGreaterThan10": 44
}
]
}